*********************************************************************************
/*   Plot R/C in 2014 against R/C in 2010, by income 		*/
*********************************************************************************
clear all

* File paths
local datapath "${mvpf_audits}/data/cleaned" 
local graphpath "${graphpath}" 
local dofilepath "${mvpf_audits}/code/prep" 

* Version of fig to produce 
global version ${version} // paper or slides

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}	

use "${mvpf_audits}/data/figures_rep/figure_4a_ap9.dta", clear

* regress 2014 rc agains 2010 rc
reg rc_lab2014 rc_lab2010 [w=obs2010], r
	local intercept : di %4.2f _b[_cons]
	local intercept_se : di %4.2f _se[_cons]
	local beta : di %4.2f _b[rc_lab2010]
	local beta_se : di %4.2f _se[rc_lab2010]

*

tw  	(function y =x, lcolor(gs12) lwidth(thin) lp(dash) range(0 40)) ///
		(scatter  rc_lab2014 rc_lab2010 if tpi_pctl!=. [w = obs2010], mc("${rc_col}") ms(Oh)) ///
		, ///
		text(10 30 "slope = `beta' (`beta_se') intercept = `intercept' (`intercept_se')") ///
		ylabel(, nogrid format(%09.0fc)) yscale(r()) ///
		xlabel(, nogrid format(%09.0fc)) xscale(r()) ///
		ytitle("Audit Revenue / Wage Costs (2014)") ///
		xtitle("Audit Revenue / Wage Costs (2010)")   ///
		legend(off) ///
		${title} ${axis_size} ///
		xlabel(, value labsize() tl() nogrid angle() ) 
	graph export "`graphpath'/scatter_rc_tpi_45degree.wmf", as(wmf) replace

* regress 2014 revenue against 2010 revenue
reg rev_tot_disc2014 rev_tot_disc2010 [w=obs2010], r
	local intercept : di %4.2f _b[_cons]
	local intercept_se : di %4.2f _se[_cons]
	local beta : di %4.2f _b[rev_tot_disc2010]
	local beta_se : di %4.2f _se[rev_tot_disc2010]
	
	li rev_tot_disc2010 rev_tot_disc2014
	
tw  	(function y =x, lcolor(gs12) lwidth(thin) lp(dash) range(0 100000)) ///
		(scatter  rev_tot_disc2014 rev_tot_disc2010 if tpi_pctl<=22 [w = obs2010], mc("${rc_col}") ms(Oh)) ///
		, ///
		ylabel(, nogrid format(%09.0fc)) yscale(r()) ///
		xlabel(, nogrid format(%09.0fc)) xscale(r()) ///
		ytitle("2014 Audit Revenue ($/audit)") ///
		xtitle("2010 Audit Revenue ($/audit)")   ///
		legend(off) ///
		${title} ${axis_size} ///
		xlabel(, value labsize() tl() nogrid angle() ) 
graph export "`graphpath'/scatter_rev_tpi_45degree.wmf", as(wmf) replace